package com.wsc.wisdomchina.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wsc.wisdomchina.R;
import com.wsc.wisdomchina.Tools.Tools;
import com.wsc.wisdomchina.javaBean.FloorActivityListBean;
import com.wsc.wisdomchina.javaBean.ModuleEventListBean;

import java.util.List;

/**
 * 楼宇活动列表适配器
 * Created by ${wangtao} on 2017/3/3.
 */

public class ModuleEventAdapter extends BaseAdapter {
    private Context context;
    private List<ModuleEventListBean.ModuleEvent> messageBeen;

    public ModuleEventAdapter(Context context, List<ModuleEventListBean.ModuleEvent> messageBeen) {
        this.context = context;
        this.messageBeen = messageBeen;
    }

    @Override
    public int getCount() {
        return messageBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return messageBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.item_floorevent,null);
            holder=new ViewHolder(view);
            view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }


        Glide.with(context).load(messageBeen.get(position).getGuideImg()).into(holder.item_lyhd_image);
        holder.item_lyhd_title.setText(messageBeen.get(position).getTitle());
        String date_time = Tools.timesTwo(String.valueOf(messageBeen.get(position).getBeginDate() / 1000));
        holder.item_lyhd_time.setText(date_time);
        holder.item_lyhd_address.setText(messageBeen.get(position).getAddr());
        return view;
    }

    public class ViewHolder{
        private ImageView item_lyhd_image;//图片
        private TextView item_lyhd_title;//标题
        private TextView item_lyhd_time;//时间
        private TextView  item_lyhd_address;//地址
        public ViewHolder(View view){
            item_lyhd_image= (ImageView) view.findViewById(R.id.item_lyhd_image);
            item_lyhd_title= (TextView) view.findViewById(R.id.item_lyhd_title);
            item_lyhd_time= (TextView) view.findViewById(R.id.item_lyhd_time);
            item_lyhd_address= (TextView) view.findViewById(R.id.item_lyhd_address);
        }
    }
}
